import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_frame/app/core/constans/storage.dart';
import 'package:flutter_frame/app/core/http/http.dart';
import 'package:flutter_frame/app/core/utils/storage_util.dart';
import 'package:flutter_frame/app/core/utils/user_manager.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';



/// 全局静态数据
class Global {
  /// 是否第一次打开
  static bool isFirstOpen = false;

  /// 是否 release
  static bool get isRelease => const bool.fromEnvironment('dart.vm.product');

  /// app 相关信息
  static PackageInfo packageInfo = PackageInfo(
    appName: 'Unknown',
    packageName: 'Unknown',
    version: 'Unknown',
    buildNumber: 'Unknown',
    buildSignature: 'Unknown',
  );


  /// init
  static Future<void> init() async {
    // 运行初始
    WidgetsFlutterBinding.ensureInitialized();

    PackageInfo.fromPlatform().then((value) => packageInfo = value);

    // DeviceUtil.init();

    await StorageUtil.init();
    // await AppLocaleUtil.init();
    UserManager.init();
    // HttpProxyUtil.init();
    HttpUtil();
    // 读取设备第一次打开
    isFirstOpen = StorageUtil.getBool(StorageConstants.firstOpen) ?? true;
    StorageUtil.setBool(StorageConstants.firstOpen, false);

    // android 状态栏为透明的沉浸
    if (GetPlatform.isAndroid) {
      const systemUiOverlayStyle =
      SystemUiOverlayStyle(statusBarColor: Colors.transparent);
      SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    }


  }
}
